package com.xhtech.base.network

/**
 * 描述　: 错误枚举类
 */

class ErrorNetWork(val id: Int, val code: String, val errMsg: String) {
    companion object {
        val NET_WORK_SUCCESS = ErrorNetWork(2000, "1000", "成功")
        val NET_WORK_ERROR = ErrorNetWork(300, "E001", "失败")
        val NET_WORK_ERROR_NO_LOGIN = ErrorNetWork(301, "E201 ", "未登录")
        val NET_WORK_ERROR_SYSTEM = ErrorNetWork(302, "1003", "系统异常")

        fun String.getCode() = when (this) {
            NET_WORK_SUCCESS.code -> NET_WORK_SUCCESS
            NET_WORK_ERROR.code -> NET_WORK_ERROR
            NET_WORK_ERROR_NO_LOGIN.code -> NET_WORK_ERROR_NO_LOGIN
            NET_WORK_ERROR_SYSTEM.code -> NET_WORK_ERROR_SYSTEM
            else -> NET_WORK_ERROR
        }.id
    }
}
